import { fromJS } from 'immutable';
import * as constants from './constants';

const defaultState = fromJS({
  workData: [],
  current: 1,
  isLoading: false,
  authorName: '',
  searchFormValue: {
    authorName: '',
  }
});

export default (state = defaultState, action) => {
  switch(action.type) {
    case constants.GET_WORKDATA:
      return state.set("workData", fromJS(action.workData));
    case constants.SEARCHFORM_CHANGE:
      return state.set("authorName", action.authorName);
    default:
      return state;
  }
}